import { Config } from 'config.js';

function upload(){
  return new Promise((resolve, reject)=>{
      wx.chooseImage({
          count: 1,
          success: (res) => {
            const tempFilePaths = res.tempFilePaths
            wx.uploadFile({
                  url: Config.restUrl + 'api/public/fileUpload',
                  header: {'Content-Type':'multipart/form-data'},
                  filePath: tempFilePaths[0],
                  name: 'file',
                  success:(data)=>{
                    console.log(JSON.parse(data.data).result.url,'返回的data');
                    
                    resolve(JSON.parse(data.data).result.url)
                  }
            })
          }
      })
  })
}

module.exports = {
  upload: upload
}